<?php
header('Content-type:text/html;charset=utf-8');
date_default_timezone_set('PRC');
$date= include './mdb.php';
// var_dump($date);
 ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>留言板</title>
	<link rel="stylesheet" type="text/css" href="css/index.css" />
	<script type="text/javascript" src='js/jquery-1.7.2.min.js'></script>

</head>
<body>
	<div id="main">
		<div id="left">
			
			<div class="cont">
				<ul>
				<?php foreach($date as $k => $v): ?>
					<li class="list">
						<div>
							<ul class="content" >
								<li class="con">
									<?php echo $v['content'] ?>
								</li>
							</ul>
							<ul class="buttom">
								<li>时间：<?php echo $v['time'] ?></li><li>   发布人：<a href=""><?php echo $v['user'] ?></a>  </li><li><a href="javascript:edit(<?php echo $k ?>)">编辑</a>  <li class="del"><a href='javascript:del(<?php echo $k ?>)'>删除</a></li>	</li>
							</ul>
								
						</div>

					</li>
				<?php endforeach ?>
				<script type="text/javascript">
				function del($k){
				var confirm = window.confirm("确认删除么？");
				if(confirm){
					window.location.href='./del.php?id='+$k;
				}
				}
				function edit($k){
					window.location.href='./edit.php?id='+$k;
				}
				</script>					
				</ul>
			</div>
		</div>
			<div id="right">
			<form action="post.php" method="post">
			<div id="form">
			<!-- <iframe height=320 width=380 src="./post.php" frameborder="0" scrolling="no"></iframe> -->
			<ul>
				<li>
					<input type="text" id="user" name="user" value=""  /><span class="usererro"></span>
				</li>
				<li>
					<textarea rows="5" cols="20" id="content" name="content" value=""></textarea><span class="conerro"></span>
					<input type="submit" id='btn' value="" />
					<input type="hidden" name="time" value="<?php echo date('Y-m-d H:i:s'); ?>" />
					
				</li>
				
			</ul>
		</div>
<script type="text/javascript">
	
	
// 用户名判断
	$('#user').change(function() {
		user =$('#user').val().length;
		// alert(user);		
		if(user<3 || user>12){
			$('.usererro').html('用户名输入有误，请输入3-12个字。');
			// $('#btn').attr('disabled',true);
		}else if(user>3 || user<12){
			$('.usererro').html('');
			
		}
	});
// 内容判断
	$('#content').change(function(){
		con =$('#content').val().length;
		if(con<10 || con>150){
			$('.conerro').html('内容输入有误，请输入10-150个字。');
			// $('#btn').attr('disabled',true);
		}else if(con>10 || con<150){
			$('.conerro').html('');
			
		}
	})
// 点击提交判断
	$('#btn').click(function(){
		alert('');
		user =$('#user').val().length;
		con =$('#content').val().length;
		alert(con);alert(user);
		if(con<10 || con>150 || user<3 || user>12 ){
			alert('填写错误！');
			$('#btn').attr('disabled',true);
		}else{
			$('#btn').attr('disabled',false);
		}
	});
		

</script>
			</form>
		</div>

	</div>
</body>
</html>